import { useCallback, useState } from 'react';
export function useInputHooks (initVal = '') {
  const [value, setValue] = useState(initVal);
  const [timer, setTimer] = useState(null);
  const [flag, setFlag] = useState(null);
  const change = useCallback((value) => {
    setValue(value);
    setFlag(false);
    if (timer) {
      clearTimeout(timer);
    };
    setTimer(setTimeout(() => {
      setFlag(true);
    }, 2000))
  }, [timer])
  return { value, onChange: (e) => { change(e.target.value) }, flag }
}